# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tunna
pkgver=41.cba006d
pkgrel=3
groups=('blackarch' 'blackarch-networking' 'blackarch-tunnel' 'blackarch-proxy'
        'blackarch-windows')
pkgdesc='a set of tools which will wrap and tunnel any TCP communication over HTTP. It can be used to bypass network restrictions in fully firewalled environments.'
arch=('any')
url='https://github.com/SECFORCE/Tunna'
license=('GPL3')
depends=('python2')
makedepends=('git')
source=("$pkgname::git+https://github.com/SECFORCE/Tunna.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname-proxy" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 proxy.py "\$@"
EOF

  cat > "$pkgdir/usr/bin/$pkgname-webserver" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 webserver.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/"*
}

